{block name="circle_layout"}
	{include file="common:common_layout"}
{/block}
{extend name="common/layout" /}
{block name="style"}
<link href="__CIRCLE_TEMPLATES_URL__/css/ubb.css" rel="stylesheet" type="text/css">
{/block}
{block name="content"}

<div class="group warp-all">
    {include file="circle:group:group_top" /}
    
    <div class="theme-editor">
    	<form method="post" id="theme_form" action="{:url('circle/manage/edit_theme')}?c_id={$c_id}&t_id={$t_id}">
            <input type="hidden" name="form_submit" value="ok" />
            <div class="quick-thread">
                <div class="quick-thread-box">
                    <div class="title">
                        <label class="mr10"><span class="t">类型：</span><span class="i">
              <select name="thtype" class="select">
                  <option value="0">默认</option>
                  <?php if(!empty($thclass_list)){?>
                  <?php foreach(($thclass_list) as $val){?>
                  <?php if($super || in_array($identity, array(1,2))){?>
                  <option value="<?php echo $val['thclass_id'];?>" <?php if($theme_info['thclass_id'] == $val['thclass_id']){?>selected="selected"<?php }?>><?php echo $val['thclass_name'];?></option>
                  <?php }else if($val['is_moderator'] == 0){?>
                  <option value="<?php echo $val['thclass_id'];?>" <?php if($theme_info['thclass_id'] == $val['thclass_id']){?>selected="selected"<?php }?>><?php echo $val['thclass_name'];?></option>
                  <?php }?>
                  <?php }?>
                  <?php }?>
              </select>
              </span></label>
                        <label><span class="t">标题：</span><span class="i">
              <input name="name" type="text" class="text" value="<?php echo $theme_info['theme_name'];?>" />
              </span></label>
                    </div>
                    <?php echo showMiniEditor('themecontent', $theme_info['theme_content'], 'manage', $affix_list, 'goods', $goods_list, $readperm, $theme_info['theme_readperm']);?>
                    <div class="bottom"> <a class="submit-btn" nctype="theme_submit" href="Javascript: void(0)">编辑话题</a> <a class="cancel-btn" nctype="theme_cancle" href="Javascript:history.go(-1);">取消</a>
                        <div id="warning"></div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="__SITE_RESOURCE__/js/fileupload/jquery.iframe-transport.js" charset="utf-8"></script>
<script type="text/javascript" src="__SITE_RESOURCE__/js/fileupload/jquery.ui.widget.js" charset="utf-8"></script>
<script type="text/javascript" src="__SITE_RESOURCE__/js/fileupload/jquery.fileupload.js" charset="utf-8"></script>
<script type="text/javascript" src="__CIRCLE_RESOURCE__/js/miniditor/jquery.insertsome.min.js"></script>
<script type="text/javascript" src="__CIRCLE_RESOURCE__/js/miniditor/ubb.insert.js" charset="utf-8"></script>
<script type="text/javascript" src="__SITE_RESOURCE__/js/jquery.validation.min.js"></script>
<script type="text/javascript">
    var c_id = <?php echo $c_id;?>;
    var t_id = <?php echo $t_id;?>;
    $(function(){
        // UBB
        $('.theme-editor').ncUBB({
            c_id : <?php echo $c_id;?>,
            t_id : <?php echo $t_id;?>,
            UBBContent : $('#themecontent'),
            UBBSubmit : $('a[nctype="theme_submit"]'),
            UBBform : $('#theme_form'),
            UBBfileuploadurl : '/circle/theme/image_upload?c_id='+c_id,
            UBBcontentleast : <?php echo intval(sysconf('circle_contentleast'));?>
	});
	// 表单验证
    $('#theme_form').validate({
        errorLabelContainer: $('#warning'),
        invalidHandler: function(form, validator) {
               $('#warning').show();
        },
    	submitHandler:function(form){
    		ajaxpost('theme_form', "<?php echo url('circle/manage/edit_theme');?>?c_id="+c_id+"&t_id="+t_id, '', 'onerror');
    	},
        rules : {
        	name : {
                required : true,
                minlength : 4,
            	maxlength : 30
            },
            themecontent : {
                required : true
                <?php if(intval(sysconf('circle_contentleast')) > 0){?>
                ,minlength : <?php echo intval(sysconf('circle_contentleast'));?>
                <?php }?>
            }
        },
        messages : {
        	name : {
                required : '请填写标题',
        minlength : '标题在4到30字符之间',
        maxlength : '标题在4到30字符之间'
        },
        themecontent  : {
            required : '请填写内容'
            <?php if(intval(sysconf('circle_contentleast')) > 0){?>
            ,minlength : "<?php printf('内容不能少于%d个字符', intval(sysconf('circle_contentleast')));?>"
            <?php }?>
        }
        }
        });
        });
</script>
{/block}